package com.jdym.back.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jdym.R;
import com.jdym.back.entity.Loan;
import com.jdym.back.entity.Put;
import com.jdym.back.entity.Uploadfile;
import com.jdym.back.service.PutService;
import com.jdym.back.service.UploadfileService;
import com.jdym.back.service.impl.PutServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.List;

/**
 * <p>
 * 放款表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-09-20
 */
@RestController
@CrossOrigin
@RequestMapping("/back/put")
public class PutController {
    @Autowired
    PutService putService;
    @Autowired
    UploadfileService uploadfileService;
    //查询 全部
    @RequestMapping("/FindAllPut")
    public R queryAll(){
        List<Put> put=putService.queryAll();
        return R.ok().data("put",put);
    }
    //查询 放款、银行、企业 三表的 放款信息

    @RequestMapping("/FindCobFirmPutAll")
    public R FindCobFirmPutAll(){
        List<Loan> loan= putService.FindCobFirmPutAll();
        Put put=null;
        System.out.println("Putid:"+loan.get(0).getPutId());
        for(int i=0;i<loan.size();i++){
            if(loan.get(i).getPutId()!=null){
                 put=putService.getPutById(loan.get(i).getPutId());
                System.out.println("查到的金额"+put);
                loan.get(i).setPut(put);
            }
        }
        return R.ok().data("loan",loan);
    }
    //模糊查询 放款信息 根据企业名称、银行名称查询
    @RequestMapping("/FindNameByKeyWord")
    public R FindNameByKeyWord(@RequestParam("keyWord") String keyWord){
        System.out.println("ke:"+keyWord);
        List<Put> puts= putService.FindNameByKeyWord(keyWord);
        return R.ok().data("puts",puts);
    }




}

